#ifndef TRAJECTORIES_H
#define TRAJECTORIES_H

#include "Trajectory.h"

_TRAJECTORY_BEGIN_

class Trajectories
{
public:
	//Trajectories() {}
	Trajectories(double Wper, double Wpar, double Wthe, double D, double p, double F):m_Wper(Wper), m_Wpar(Wpar), m_Wthe(Wthe), m_D(D), m_p(p), m_F(F) {}
	Trajectories(const Trajectories& obj) 
	{ 
		m_Trajs.clear();
		m_Trajs = obj.m_Trajs;
	}
	Trajectories& operator=(const Trajectories& obj)
	{
		m_Trajs.clear();
		m_Trajs = obj.m_Trajs;
		return *this;
	}

public:
	inline Trajectory& operator[](int index){ return m_Trajs[index]; }
	inline const Trajectory& operator[](int index) const { return m_Trajs[index]; }
	inline int size() const { return m_Trajs.size(); }
	inline void resize(int size) { m_Trajs.resize(size); }
	inline void addTraj(const Trajectory& traj) { m_Trajs.push_back(traj); }

public:
	void readFromFile(const std::string& filename, int nameIndex, int startDimension, int endDimension);
	void findOutlier();
	const std::vector<int> getOT() const { return m_OT; }
	void writeResult(const std::string& outputFileName) const;

protected:
	double lb(const std::vector<int>& CPi, const std::vector<int>& CPk, int index_i, int index_j, int index_k, int index_l);
	double ub(const std::vector<int>& CPi, const std::vector<int>& CPk, int index_i, int index_j, int index_k, int index_l);

private:

	void calcCP(std::vector<std::vector<int>> &CP);
	void calcCLset(std::vector<std::vector<CL>> &CLset, vector<vector<CTR>> &CTRset);
	void calcCTRset(std::vector<std::vector<CTR>> &CTRset, const std::vector<std::vector<CL>> &CLset);
	void calcadj(std::vector<std::vector<double>> &adj);
	void calcOP(std::vector<std::vector<int>> &OP, const std::vector<std::vector<CTR>> &CTRset, const std::vector<std::vector<double>> &adj);
	void calcOT(const std::vector<std::vector<int>> &OP);

private:
	std::vector<Trajectory> m_Trajs;
	std::vector<int> m_OT;
	double m_Wper;
	double m_Wpar;
	double m_Wthe;
	double m_D;
	double m_p;
	double m_F;

	double costTime;
};

_TRAJECTORY_END_

#endif

